function model = libsvmtrain_f(lbl, data, settings, c, g, ind)
dataname = [settings.title,'_',num2str(ind),'.train'];
modelname = [settings.title,'_',num2str(ind),'.model'];
libsvmwrite(dataname, lbl, sparse(data));
cmd = [settings.svmtrain,' ',settings.train_opt,' -c ',num2str(c), ...
    ' -g ',num2str(g),' ',dataname,' ',modelname];
if settings.verbose >= 2
    disp(cmd);
end
[e, w] = system(cmd);
if settings.verbose >= 2
    disp(w);
end
if e ~= 0
    error([num2str(ind),': Execution failed with error code: ',num2str(e)]);
end
delete(dataname);
model = struct('file', modelname);
end
